package dk.au.cs.bdsi.mail.repositories;

import java.util.HashMap;
import java.util.LinkedList;

import dk.au.cs.bdsi.core.repositories.AbstractRepository;
import dk.au.cs.bdsi.core.representation.Identifier;
import dk.au.cs.bdsi.mail.domain.Mail;

public class MailRepository extends AbstractRepository<Identifier, Mail> {
	private static MailRepository Instance = null;
	
	private MailRepository() {
		super(new HashMap<Identifier, Mail>(), new LinkedList<Mail>());
	}
	
	/**
	 * Retrieve the current message repository instance.
	 * 
	 * @return Current repository instance
	 */
	public static MailRepository current() {
		if (Instance == null) {
			synchronized (MailRepository.class) {
				if (Instance == null) {
					Instance = new MailRepository();
				}
			}
		}
		return Instance;
	}
	
	@Override
	protected Identifier generateKey() {
		// Optimistic implementation, dependent on the uniqueness of Identifier
		return new Identifier();
	}

}
